package ysq.xyg.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import ysq.xyg.dao.DbShareDao;
import ysq.xyg.model.DbShare;
import ysq.xyg.service.DbShareService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yu sheng qiang
 * @create 2017-03-22 15:37
 **/
@Service("dbShareService")
public class DbShareServiceImpl extends BaseServiceImpl<DbShare> implements DbShareService {

    @Resource
    private DbShareDao dbShareDao;

    @Autowired
    public void setBaseDao(DbShareDao dbShareDao) {
        this.baseDao = dbShareDao;
    }

    @Override
    public PageInfo<DbShare> pageInfo(DbShare dbShare, int pageSize, int pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        //通用Example查询
        Example example = new Example(DbShare.class);
        Example.Criteria criteria = example.createCriteria();
        List<DbShare> list=dbShareDao.selectByExample(example);
        return new PageInfo<DbShare>(list);
    }
    @Override
    public DbShare selectDbShare() {
        List<DbShare> list=dbShareDao.selectAll();
        if(list!=null&&list.size()>0){
            return list.get(0);
        }else{
            return null;
        }
    }
}
